//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "FdmBlackScholesMultiStrikeMesher.h"
using namespace Cephei::QL::Experimental::Finitedifferences;
#include <gen/QL/Processes/GeneralizedBlackScholesProcess.h>
#include <gen/QL/Experimental/Finitedifferences/Fdm1dMesher.h>
using namespace Cephei::QL::Processes;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::CFdmBlackScholesMultiStrikeMesher (boost::shared_ptr<QuantLib::FdmBlackScholesMultiStrikeMesher>& childNative, Object^ owner) : CFdm1dMesher(CFdmBlackScholesMultiStrikeMesher::typeid)
{
#ifdef HANDLE
	_phFdmBlackScholesMultiStrikeMesher = NULL;
#endif
	_ppFdmBlackScholesMultiStrikeMesher = &childNative;
    _ppFdm1dMesher = new boost::shared_ptr<QuantLib::Fdm1dMesher> (boost::dynamic_pointer_cast<QuantLib::Fdm1dMesher> (*_ppFdmBlackScholesMultiStrikeMesher));
}
Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::CFdmBlackScholesMultiStrikeMesher (QuantLib::FdmBlackScholesMultiStrikeMesher& childNative, Object^ owner) : CFdm1dMesher(CFdmBlackScholesMultiStrikeMesher::typeid)
{
#ifdef HANDLE
	_phFdmBlackScholesMultiStrikeMesher = NULL;
#endif
	_ppFdmBlackScholesMultiStrikeMesher = new boost::shared_ptr<QuantLib::FdmBlackScholesMultiStrikeMesher> (&childNative);
    _ppFdm1dMesher = new boost::shared_ptr<QuantLib::Fdm1dMesher> (boost::dynamic_pointer_cast<QuantLib::Fdm1dMesher> (*_ppFdmBlackScholesMultiStrikeMesher));
    _FdmBlackScholesMultiStrikeMesherOwner = owner;
    _Fdm1dMesherOwner = owner;
}

Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::CFdmBlackScholesMultiStrikeMesher (CFdmBlackScholesMultiStrikeMesher^ copy) : CFdm1dMesher(CFdmBlackScholesMultiStrikeMesher::typeid)
{
#ifdef HANDLE
	_phFdmBlackScholesMultiStrikeMesher = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppFdmBlackScholesMultiStrikeMesher = new boost::shared_ptr<QuantLib::FdmBlackScholesMultiStrikeMesher> (copy->GetShared());
        _ppFdm1dMesher = new boost::shared_ptr<QuantLib::Fdm1dMesher> (boost::dynamic_pointer_cast<QuantLib::Fdm1dMesher> (*_ppFdmBlackScholesMultiStrikeMesher));
    }
}
Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::CFdmBlackScholesMultiStrikeMesher (System::Type^ t) : CFdm1dMesher(CFdmBlackScholesMultiStrikeMesher::typeid)
{
#ifdef HANDLE
	_phFdmBlackScholesMultiStrikeMesher = NULL;
#endif
	if (!t->IsSubclassOf(CFdmBlackScholesMultiStrikeMesher::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::CFdmBlackScholesMultiStrikeMesher (QuantLib::Handle<QuantLib::FdmBlackScholesMultiStrikeMesher>& childNative, Object^ owner)  : CFdm1dMesher(CFdmBlackScholesMultiStrikeMesher::typeid)
{
	_phFdmBlackScholesMultiStrikeMesher = &childNative;
	_ppFdmBlackScholesMultiStrikeMesher = &static_cast<boost::shared_ptr<QuantLib::FdmBlackScholesMultiStrikeMesher>>(childNative.currentLink());
    _ppFdm1dMesher = new boost::shared_ptr<QuantLib::Fdm1dMesher> (boost::dynamic_pointer_cast<QuantLib::Fdm1dMesher> (*_ppFdmBlackScholesMultiStrikeMesher));
    _FdmBlackScholesMultiStrikeMesherOwner = owner;
}
Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::CFdmBlackScholesMultiStrikeMesher (QuantLib::Handle<QuantLib::FdmBlackScholesMultiStrikeMesher> childNative)  : CFdm1dMesher(CFdmBlackScholesMultiStrikeMesher::typeid)
{
	_phFdmBlackScholesMultiStrikeMesher = &childNative;
	_ppFdmBlackScholesMultiStrikeMesher = &static_cast<boost::shared_ptr<QuantLib::FdmBlackScholesMultiStrikeMesher>>(childNative.currentLink());
    _ppFdm1dMesher = new boost::shared_ptr<QuantLib::Fdm1dMesher> (boost::dynamic_pointer_cast<QuantLib::Fdm1dMesher> (*_ppFdmBlackScholesMultiStrikeMesher));
}
#endif
#ifdef STRUCT
Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::CFdmBlackScholesMultiStrikeMesher (QuantLib::FdmBlackScholesMultiStrikeMesher childNative)  : CFdm1dMesher(CFdmBlackScholesMultiStrikeMesher::typeid)
{
#ifdef HANDLE
	_phFdmBlackScholesMultiStrikeMesher = NULL;
#endif
	_ppFdmBlackScholesMultiStrikeMesher = new boost::shared_ptr<QuantLib::FdmBlackScholesMultiStrikeMesher> (new QuantLib::FdmBlackScholesMultiStrikeMesher (childNative));
    _ppFdm1dMesher = new boost::shared_ptr<QuantLib::Fdm1dMesher> (boost::dynamic_pointer_cast<QuantLib::Fdm1dMesher> (*_ppFdmBlackScholesMultiStrikeMesher));
}
#endif

Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::~CFdmBlackScholesMultiStrikeMesher ()
{
    if (_ppFdmBlackScholesMultiStrikeMesher != NULL)
    {
	    delete _ppFdmBlackScholesMultiStrikeMesher;
        _ppFdmBlackScholesMultiStrikeMesher = NULL;
    }
}
Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::!CFdmBlackScholesMultiStrikeMesher ()
{
    if (_ppFdmBlackScholesMultiStrikeMesher != NULL)
    {
	    delete _ppFdmBlackScholesMultiStrikeMesher;
    }
}
QuantLib::FdmBlackScholesMultiStrikeMesher& Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::GetReference ()
{
    if (_ppFdmBlackScholesMultiStrikeMesher == NULL) throw gcnew NativeNullException ();
	return **_ppFdmBlackScholesMultiStrikeMesher;
}
boost::shared_ptr<QuantLib::FdmBlackScholesMultiStrikeMesher>& Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::GetShared ()
{
    if (_ppFdmBlackScholesMultiStrikeMesher == NULL) throw gcnew NativeNullException ();
	return *_ppFdmBlackScholesMultiStrikeMesher;
}
QuantLib::FdmBlackScholesMultiStrikeMesher* Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::GetPointer ()
{
    if (_ppFdmBlackScholesMultiStrikeMesher == NULL) throw gcnew NativeNullException ();
	return &**_ppFdmBlackScholesMultiStrikeMesher;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::FdmBlackScholesMultiStrikeMesher>& Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::GetHandle ()
{
	if (_phFdmBlackScholesMultiStrikeMesher == NULL)
	{
		_phFdmBlackScholesMultiStrikeMesher = new Handle<QuantLib::FdmBlackScholesMultiStrikeMesher> (*_ppFdmBlackScholesMultiStrikeMesher);
	}
	return *_phFdmBlackScholesMultiStrikeMesher;
}
#endif
bool Cephei::QL::Experimental::Finitedifferences::CFdmBlackScholesMultiStrikeMesher::HasNative () 
{
	return (_ppFdmBlackScholesMultiStrikeMesher != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

